package com.timothy.fund.adapter;

import java.util.HashMap;
import java.util.List;

import com.timothy.fund.adapter.FundCatagoryAdaptor.ViewHolder;
import com.timothy.fund.bean.FundCatagory;
import com.timothy.fund.bean.StockA;
import com.timothy.fund.ui.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

public class StockAAdaptor extends BaseAdapter {
	private Context 					mContext;
	private List<StockA> 				listItems;
	private LayoutInflater 				mInflater;
	
	HashMap<Integer,View> viewMap = new HashMap<Integer,View>(); 
	
	static class ViewHolder{				
	        public TextView quote;  
		    public TextView name;  
		    public TextView price;
		    public TextView value;
		    public TextView discount;
//		    public TextView rate;
//		    public TextView endDate;  
//		    public TextView convert;
	 }  
	
	public StockAAdaptor(Context context, List<StockA> data) {
		this.mContext = context;
		mInflater = LayoutInflater.from(context); 
		this.listItems = data;
	}

	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listItems.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;  
        if (convertView == null){  
            holder = new ViewHolder();  
            convertView = mInflater.inflate(R.layout.stock_a_item, null);  
            
			holder.quote = (TextView) convertView.findViewById(R.id.quote);
			holder.name = (TextView) convertView.findViewById(R.id.name);
			holder.price = (TextView) convertView.findViewById(R.id.price);
			holder.value = (TextView) convertView.findViewById(R.id.value);
			holder.discount = (TextView) convertView.findViewById(R.id.discount);
//			holder.rate = (TextView) convertView.findViewById(R.id.rate);
//			holder.endDate = (TextView) convertView.findViewById(R.id.end_date);
//			holder.convert = (TextView) convertView.findViewById(R.id.convert);
			
            convertView.setTag(holder);  
        }else {  
            holder = (ViewHolder) convertView.getTag();  
        }  
        
		StockA stocka = listItems.get(position);
		
		holder.quote.setText(stocka.getQuote());
		holder.name.setText(stocka.getName());
		holder.price.setText(stocka.getPrice());
		holder.value.setText(stocka.getValue());
		holder.discount.setText(stocka.getDisCount());
//		holder.rate.setText(stocka.getRate());
//		holder.endDate.setText(stocka.getEndDate());
//		holder.convert.setText(stocka.getConvert());
		
        return convertView; 
        
	}

}
